package com.example.isoftservice.service.impl;

import com.example.isoftservice.mapper.LogsMapper;
import com.example.isoftservice.pojos.Logs;
import com.example.isoftservice.service.LogsService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class LogsServiceImpl implements LogsService {

    @Resource
    private LogsMapper logsMapper;
    @Override
    public Map<String, Object> searchByPage(Integer pageNo, Integer pageSize, Logs logs) {
        Map<String, Object> map = new HashMap<>();
        PageHelper.startPage(pageNo,pageSize);
        List<Map<String,Object>> resultList = logsMapper.selectByPage(logs);
        PageInfo<Map<String,Object>> info = new PageInfo<>(resultList);
        map.put("total",info.getTotal());
        map.put("rows",info.getList());
        return map;
    }

    @Override
    public Boolean addLogs(Logs logs) {
        return logsMapper.insert(logs) == 1 ? true : false;
    }

    @Override
    public Boolean removeLogs(Integer[] ids) {
        return logsMapper.delete(ids) >= 1 ? true :false;
    }
}
